<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="projects.issue" %>
<%@ page import="userInteraction.readUserInformation" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="issue" class="projects.issue"></jsp:useBean>
<jsp:setProperty property="*" name="issue"/>
<jsp:useBean id="user" class="userInteraction.readUserInformation"></jsp:useBean>
<jsp:setProperty property="*" name="user"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>

<%
	if (session.getAttribute("loggedIn") == null) {
		response.sendRedirect("../User/index.jsp");
		}
%>

<body>
	<%
	readUserInformation userInfo =new readUserInformation();
	issue newIssue = new issue();
	newIssue.setTaskId(Integer.parseInt(request.getParameter("hTaskId")));
	newIssue.setIssueDescription(request.getParameter("issueDescription"));
	Integer userId = userInfo.readUserId(session.getAttribute("loggedIn").toString());
	String url = "../Tasks/task.jsp?id="+request.getParameter("hTaskId");
	if (newIssue.createIssue(userId)){
		session.setAttribute("postback", "true");
		session.setAttribute("createIssue", "true");
		response.sendRedirect(url); 
	}
	else
	{
		session.setAttribute("postback", "true");
		session.setAttribute("createIssue", "false");
		response.sendRedirect(url);
	}
	
	%>
</body>
</html>